export default async ({ Vue, options, router, siteData, isServer }) => {
    if (!isServer) {
        // Dynamically import styles and components only on the client side
        await import('../../../dist/umd/style.css');
        await import('element-ui/lib/theme-chalk/index.css');

        const { MasterModal, MasterDataModal } = await import('../../../dist/umd/index');

        Vue.use(MasterModal);
        Vue.use(MasterDataModal);

        const requireComponent = require.context(
            // The relative path of the component directory
            './components',
            // Whether to look in subdirectories
            true,
            // The regular expression used to match base component filenames
            /[A-Z]\w+\.(vue|js)$/
        );

        requireComponent.keys().forEach(fileName => {
            // Get component config
            const componentConfig = requireComponent(fileName);

            // Get PascalCase name of component
            const componentName = fileName
                .split('/')
                .pop()
                .replace(/\.\w+$/, '');
            // Globally register component
            Vue.component(
                componentName,
                componentConfig.default || componentConfig
            );
        });
    }
};
